<template>
  <div class="card-box">
    <!-- 视频组件的封装 -->
    <div class="list-bar" v-if="title">
      <span>{{ title }}</span>
      <a href="#" class="a-rank" v-if="title === '热门推荐' && icon">
        <i class="iconfont icon-rankfill"></i>
        <span>排行榜</span>
        <i class="iconfont icon-arrow-right"></i>
      </a>
      <a href="#" class="a-more" v-if="title !== '热门推荐' && icon">
        <span>查看更多</span>
        <i class="iconfont icon-arrow-right"></i>
      </a>
    </div>
    <div class="video-list-box">
      <a class="video-box" v-for="video in videos" :key="video._id">
        <div class="card">
          <img :src="video.img" alt="" @click="$router.push(`/video/${video._id}`).catch(err => {})" />
          <div class="count">
            <span><i class="iconfont icon-video_horizontal_outlined"></i>{{
                video.playNum > 10000
                  ? video.playNum / 10000 + '万'
                  : video.playNum.toString()
              }}</span>
            <span><i class="iconfont icon-danmu"></i>{{
                video.danmu > 10000
                  ? video.danmu / 10000 + '万'
                  : video.danmu.toString()
              }}</span>
          </div>
        </div>
        <p class="title">{{ video.title }}</p>
      </a>
    </div>
  </div>
</template>

<script>
export default {
  props: ['videos', 'title', 'icon'],
  data () {
    return {}
  },
  methods: {}
}
</script>

<style lang="scss">
.card-box {
  display: flex;
  width: 100%;
  flex-direction: column;
  .list-bar {
    display: flex;
    justify-content: space-between;
    height: 20px;
    padding: 5px;
    font-size: 14.4px;
    .a-rank {
      color: #ffa726;
      span {
        padding: 0px 2px;
      }
    }
    .a-more {
      color: #ccc;
    }
  }
  .video-list-box {
    display: flex;
    justify-content: space-between;
    width: 100%;
    flex-wrap: wrap;
    .video-box {
      display: inline-block;
      width: 48%;
      height: 130px;
      margin: 7.68px 0;
      .card {
        position: relative;
        height: 93px;
        width: 100%;
        img {
          width: 100%;
          height: 93px;
        }
        .count {
          font-size: 12px;
          width: 100%;
          position: absolute;
          bottom: 0px;
          padding-bottom: 5px;
          display: flex;
          justify-content: space-between;
          align-items: center;
          color: #fff;
          background: linear-gradient(0deg, rgba(0, 0, 0, 0.85), transparent);
          span:nth-child(1) {
            margin-left: 5px;
          }
          span:nth-child(2) {
            margin-right: 5px;
          }
          .iconfont {
            padding-right: 2px;
          }
          .icon-video_horizontal_outlined {
            position: relative;
            top: 2px;
            left: 2px;
          }
          .icon-danmu {
            font-size: 8px;
          }
        }
      }
      .title {
        color: #212121;
        height: 32px;
        line-height: 16px;
        font-size: 12px;
        margin-top: 5px;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
      }
    }
  }
}
</style>
